import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../components/home/Home.vue';
import First from '../components/first/First.vue';
import Second from '../components/second/Second.vue';
import Third from '../components/third/Third.vue';
import Zero from '../components/zero/Zero.vue';
import Login from '../components/login/Login.vue';
import Register from '../components/register/Register.vue';
import My from '../components/my/My.vue';
import Fourth from '../components/fourth/Fourth.vue';
import Detail from '../components/detail/Detail.vue';
import Play from '../components/play/Play.vue';
Vue.use(VueRouter)
    // 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
const routes = [{
        path: '/',
        name: 'Home',
        component: Home,
        redirect: '/home',
        children: [{
                path: '/first',
                name: 'First',
                component: First
            },
            {
                path: '/second',
                name: 'Second',
                component: Second
            },
            {
                path: '/third',
                name: 'Third',
                component: Third
            },
            {
                path: '/home',
                name: 'Zero',
                component: Zero
            },
            {
                path: '/fourth',
                name: 'Fourth',
                component: Fourth
            }, {
                path: '/detail/:id',
                name: 'Detail',
                component: Detail
            },
        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: Login
    },
    {
        path: '/register',
        name: 'Register',
        component: Register
    },
    {
        path: '/play',
        name: 'Play',
        component: Play
    },
    {
        path: '/my',
        name: 'My',
        component: My
    },
]

const router = new VueRouter({
    mode: 'hash',
    hashbang: true,
    base: process.env.BASE_URL,
    routes
})
router.beforeEach((to, from, next) => {
    // console.log(to, from);
    next();
})
export default router